package com.s3u4.concurrence.pool;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created by Captain on 28/03/2018.
 */
public class ScheduleClient {

    public static void main(String[] args) {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

//        executorService.scheduleAtFixedRate() () -> {
        executorService.scheduleWithFixedDelay( () -> {
            try {
                Thread.sleep(2000);
                System.out.println("------------ " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } , 0, 3000 , TimeUnit.MILLISECONDS);

    }

}
